
package com.primeton.eos.oss.model.service;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.eos.system.utility.PageResultList;

import com.eos.data.datacontext.DataContextManager;
import com.eos.data.datacontext.IMUODataContext;

import com.primeton.eos.oss.model.dao.CrecSysOrganizationHisDao;
import com.primeton.eos.oss.model.newdataset.CrecSysOrganizationHis;

@Service
public class CrecSysOrganizationHisService {

    @Autowired
    private CrecSysOrganizationHisDao crecSysOrganizationHisDao;


    public PageResultList<CrecSysOrganizationHis> queryCrecSysOrganizationHissWithPage(String code,  int pageSize, int pageIndex) {
        //TODO 记录日志
        return crecSysOrganizationHisDao.queryCrecSysOrganizationHissWithPage(code,  pageSize, pageIndex);
    }

    public CrecSysOrganizationHis getCrecSysOrganizationHisById(String id) {
        //TODO 记录日志
        return crecSysOrganizationHisDao.getEntity(CrecSysOrganizationHis.QNAME, id);
    }

    @Transactional
    public void createCrecSysOrganizationHis(CrecSysOrganizationHis crecSysOrganizationHis) {
        //TODO 记录日志
    	String userName = "";
		IMUODataContext muo = DataContextManager.current().getMUODataContext();
		if (muo != null) {
			userName = muo.getUserObject().getUserName();
		}
        crecSysOrganizationHis.set("createUser", userName);
        crecSysOrganizationHis.set("createTime", new Date());
        crecSysOrganizationHis.set("updateUser", userName);
        crecSysOrganizationHis.set("updateTime", new Date());

        crecSysOrganizationHisDao.getPrimaryKey(crecSysOrganizationHis);
        crecSysOrganizationHisDao.insertEntity(crecSysOrganizationHis);
    }
    
    @Transactional
    public void modifyCrecSysOrganizationHis(CrecSysOrganizationHis crecSysOrganizationHis) {
        //TODO 记录日志
     	String userName = "";
		IMUODataContext muo = DataContextManager.current().getMUODataContext();
		if (muo != null) {
			userName = muo.getUserObject().getUserName();
		}
        crecSysOrganizationHis.set("updateUser", userName);
        crecSysOrganizationHis.set("updateTime", new Date());
 
        crecSysOrganizationHisDao.updateEntity(crecSysOrganizationHis);
    }
    
     @Transactional
    public void removeCrecSysOrganizationHis(CrecSysOrganizationHis[] crecSysOrganizationHis) {
        //TODO 记录日志
        crecSysOrganizationHisDao.deleteEntity(crecSysOrganizationHis);
    }

}





